/**
 * 分页的处理
 */
var PageList = function() {
    var self = this;
    self.pageSize = 100;
    self.currPage = 1;
    self.totalPage = -1;
    self.total = -1;
    self.jumpPage = null;
};
PageList.prototype = {};

PageList.prototype.fillPages = function(total, currPage, totalPage, pageSize, div) {
    var self = this;
    self.total = total;
    self.totalPage = totalPage;

    self.currPage = currPage;
    div = div || ".zxf_pagediv";
    self.container = $(div);
    if (self.container.length == 0) {
        console.error("节点不存在", div);
    }
    $(div).empty();
    $(div).createPage({
        pageNum: totalPage,
        current: currPage,
        shownum: self.phone ? 5 : 15,
        phone: self.phone,
        denyTrai: self.denyTrai,
        backfun: function(e) {
            // 跳转到指定页面
            if (self.jumpPage) self.jumpPage(e.current);
        }
    });
    $(div + " .total").html("共 " + total + " 条");
    $(div + " .pageS select").val(pageSize);

    $(div + " .pageS select").change(function() {
        self.currPage = 1;
        if (self.jumpPage) self.jumpPage(1);
    });
}

PageList.prototype.getPageSize = function() {
    var self = this;
    if (! self.container) return 20;
    return parseInt(self.container.find(".pageS select").val());
}

PageList.prototype.setPageSize = function(size) {
    var self = this;
    if (self.container)
        self.container.find(".pageS select").val(size);
}
